package com.zjitc.controller;

import com.zjitc.model.Category;
import com.zjitc.model.Product;
import com.zjitc.service.CategoryService;
import com.zjitc.service.ProductService;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

/**
 * Create by IntelliJ IDEA
 *
 * @author: jsonor
 * @date-Time: 2018/4/25 16:38
 * @description:
 *
 */
@Controller
public class IndexController {
    @Autowired
    private ProductService productService;

    @Autowired
    private CategoryService categoryService;

  @RequestMapping("/index")
  private ModelAndView index(@RequestParam(defaultValue = "1") int pageSize,
      @RequestParam(defaultValue = "10") int pageNum) {
    ModelAndView modelAndView = new ModelAndView();
    List<Category> categoryList=categoryService.findCategoryList();
    modelAndView.addObject("cl",categoryList);
    List<Product> listIs_hot= productService.findIs_hot();
    List<Product> listNew = productService.findNew();
    modelAndView.addObject("listIs_hot",listIs_hot);
    modelAndView.addObject("listNew",listNew);
    modelAndView.setViewName("/user/index.jsp");
    return modelAndView;
    }
  }
